<?php

function edit_program_student_course($str){
	$sql = 'select `id`,`'.$str.'` cs from `program_student_course` where `'.$str.'` not like "%-%"';
	$row = mysql_query($sql);
	$up_sql = '';
	while ($ret = mysql_fetch_array($row)){
		if(strpos($ret['cs'],'/')){
			$date = explode('/',$ret['cs']);
			$date1 = $date[2].'-'.$date[1].'-'.$date[0];
			$up_sql = 'update `program_student_course` set `'.$str.'`=\''.$date1.'\' where id='.$ret['id'];
		}else if(strpos($ret['cs'],',')){
			$up_sql = 'update `program_student_course` set `'.$str.'`=\''.date("Y-m-d",strtotime($ret['cs'])).'\' where id='.$ret['id'];
		}else{
			$up_sql = 'update `program_student_course` set `'.$str.'`=\'0000-00-00\' where id='.$ret['id'];
		}
		//echo $up_sql."\r\n";
		mysql_query($up_sql);
	}
}

//更改,`class_start`,`class_end`,`class_date3`,`class_date4`,`class_date5` 
function edit_project_course_info($str){ 
	$sql = 'select `id`,`'.$str.'` cs from `project_course_info` where `'.$str.'` not like "%-%"';
	
	$row = mysql_query($sql);
	$up_sql = '';
	while ($ret = mysql_fetch_array($row)){
		if(strpos($ret['cs'],'/')){
			$date = explode('/',$ret['cs']);
			$date1 = $date[2].'-'.$date[1].'-'.$date[0];
			$up_sql = 'update `project_course_info` set `'.$str.'`=\''.$date1.'\' where id='.$ret['id'];
		}else if(strpos($ret['cs'],',')){
			$up_sql = 'update `project_course_info` set `'.$str.'`=\''.date("Y-m-d",strtotime($ret['cs'])).'\' where id='.$ret['id'];
		}else{
			$up_sql = 'update `project_course_info` set `'.$str.'`=\'0000-00-00\' where id='.$ret['id'];
		}
		//echo $up_sql."\r\n";
		mysql_query($up_sql);
	}
}

	$conn = mysql_connect('localhost','root','');
	mysql_select_db('admin_crm');
	mysql_query("set names 'utf8'");

	edit_program_student_course('class_start');
	edit_program_student_course('class_end');
	edit_program_student_course('class_date3');
	edit_program_student_course('class_date4');
	edit_program_student_course('class_date5');
	//`class_start`,`class_end`,`class_date3`,`class_date4`,`class_date5` 
	edit_project_course_info('class_start');
	edit_project_course_info('class_end');
	edit_project_course_info('class_date3');
	edit_project_course_info('class_date4');
	edit_project_course_info('class_date5');

	mysql_close($conn);
?>